x = int(input("请输入整数x="))
y = int(input("请输入整数y="))
z = int(input("请输入整数z="))
if x*x+y*y+z*z>1000:
  m = x*x+y*y+z*z
  n = m%1000
  print(n)
else:
  i = x+y+z
  print(i)
